fprintf(STDOUT,"Accepts redirection and pipes.\nOmit other parameters for help and prompt\n");
/* Initialize output drive to default drive */
outdrv[0] = '\0';
/* But prepare for a specific drive */
outdrv[1] = ':';
outdrv[2] = '\0'; /* string terminator */
/* Process the parameters in order */
for(i = 1; i < argc; ++i)
obey(argv[i]);
if(argc < 2) {
fprintf(STDOUT, "Parameters are from command line or one-at-a-time from standard\ninput and are output drives and input file names. Empty to quit.\n");
do {
fprintf(STDOUT, "\n*");
for(i = 0; i < 16; ++i) {
if((c = getchar()) == EOF)
c = '\n'; /* fake empty (exit) command */
if((inparg[i] = c) == '\n') {
inparg[i] = '\0';
break;
}
}
if(inparg[0] != '\0')
obey(inparg);
} while(inparg[0] != '\0');
}
dioflush(); /* clean up any directed io */
}
obey(p)
char *p;
{
char *q;
char outfile[16]; /* output file spec. */
if(*p == '-') {
/* toggle debug option */
debug = !debug;
return;
}
if(*(p + 1) == ':') {
/* Got a drive */
if(isalpha(*p)) {
if(*(p+2) == '\0') {
/* Change output drive */
printf("\nOutput drive =%s",p);
outdrv[0] = *p;
return;
}
} else {
fprintf(STDOUT, "\nERROR - Ignoring %s", p);
return;
}
}
/* Check for ambiguous (wild-card) name */
for(q = p; *q != '\0'; ++q)
if(*q == '*' || *q == '?') {
fprintf(STDOUT, "\nAmbiguous name %s ignored", p);
return;
}
/* First build output file name */
outfile[0] = '\0'; /* empty */
strcat(outfile, outdrv); /* drive */
strcat(outfile, (*(p + 1) == ':') ? p + 2 : p); /* input name */